package com.zz.ai.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.embedding.TokenCountBatchingStrategy;
import org.springframework.ai.moonshot.MoonshotChatModel;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.vectorstore.VectorStore;
//import org.springframework.ai.vectorstore.redis.RedisVectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import redis.clients.jedis.JedisPooled;

@Configuration
public class Init {

    @Resource
    private MoonshotChatModel model;

    @Resource
    private OllamaChatModel ollamaChatModel;

//    @Resource
    public ChatMemory chatMemory =  new InMemoryChatMemory();

    @Bean
    public ChatClient chatClient() {

        return ChatClient.builder(ollamaChatModel)
                .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory))
                .build();
    }

    @Bean
    public ChatClient moonshotChatClient() {

        return ChatClient.builder(model)
                .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory))
                .build();
    }

//    @Bean
//    public ChatMemory chatMemory(){
//        return new InMemoryChatMemory();
//    }



}
